// IImage.h: interface for the IImage class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_IIMAGE_H__B746956A_7BA9_43E3_B54F_098DCB2A9889__INCLUDED_)
#define AFX_IIMAGE_H__B746956A_7BA9_43E3_B54F_098DCB2A9889__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

struct MBBitmapData
{
public:
	MBBitmapData(){memset(this,0,sizeof(MBBitmapData));};
	MBBitmapData(UINT w,UINT h,UINT nPB){memset(this,0,sizeof(MBBitmapData));CreatBuffer(w,h,nPB);};
	MBBitmapData(MBBitmapData* pData){
		memcpy(this,pData,sizeof(MBBitmapData));
		Scan0 = NULL;
		CreatBuffer(Width,Height,nPixelBytes);
		size_t uBufferSize = Height*Stride;
		if (uBufferSize>0)
			memcpy(Scan0,pData->Scan0,uBufferSize);
	}

	~MBBitmapData(){if(Scan0)delete Scan0;};
	void CreatBuffer(UINT w,UINT h,UINT nPB){
		if(Scan0)delete Scan0;
		Width = w;
		Height = h;
		nPixelBytes = nPB;
		Stride = ((nPixelBytes*Width+3)/4)*4;
		size_t uBufferSize = Height*Stride;
		if (uBufferSize>0)
		{
			Scan0 = malloc(uBufferSize);
			memset(Scan0,0,uBufferSize);
		}

	};
	
	UINT X;
	UINT Y;
	UINT Width;
	UINT Height;
    INT Stride;
	UINT nPixelBytes;
    VOID* Scan0;
};

struct IImage  
{
public:
	IImage();
	virtual ~IImage();
	virtual int GetWidth()=0;
	virtual int GetHeight()=0;
	virtual void GetImageData(MBBitmapData& mbData,UINT x,UINT y,UINT w,UINT h)=0;
	virtual void SetImageData(MBBitmapData& mbData)=0;
	virtual LRESULT Draw(Graphics* g,float fZoom,int nOffX,int nOffY,int nScreenW,int nScreenH)=0; // Draw the image itself.
};

typedef IImage* PIImage;

#endif // !defined(AFX_IIMAGE_H__B746956A_7BA9_43E3_B54F_098DCB2A9889__INCLUDED_)
